//
//  ASMyPortraitCell.m
//  AttendenceSys
//
//  Created by 窦芳俊 on 16/2/29.
//  Copyright © 2016年 窦芳俊. All rights reserved.
//

#import "ASMyPortraitCell.h"

#define Portrait_Image_Width   90
#define Portrait_Image_Height  90

@implementation ASMyPortraitCell


- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        CGFloat bgWidth = [[UIScreen mainScreen] bounds].size.width;
        
        // leftImage
        _leftImage = [[UIImageView alloc] initWithFrame:CGRectZero];
        _leftImage.frame = CGRectMake((bgWidth - Portrait_Image_Width * 2) / 3, 20, Portrait_Image_Width, Portrait_Image_Height);
        _leftImage.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:_leftImage];
        
        // rightImage
        _rightImage = [[UIImageView alloc] initWithFrame:CGRectZero];
        _rightImage.frame = CGRectMake(_leftImage.frame.origin.x + Portrait_Image_Width + ((bgWidth - Portrait_Image_Width * 2) / 3),
                                       20,
                                       Portrait_Image_Width,
                                       Portrait_Image_Height);
        _rightImage.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:_rightImage];
        
        // leftButton
        _leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _leftButton.backgroundColor = [UIColor clearColor];
        _leftButton.frame = CGRectMake(_leftImage.frame.origin.x,
                                       _leftImage.frame.origin.y,
                                       _leftImage.frame.size.width,
                                       _leftImage.frame.size.height);
        [_leftButton addTarget:self action:@selector(leftTouch) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_leftButton];
        
        // rightButton
        _rightButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _rightButton.backgroundColor = [UIColor clearColor];
        _rightButton.frame = CGRectMake(_rightImage.frame.origin.x,
                                        _rightImage.frame.origin.y,
                                        _rightImage.frame.size.width,
                                        _rightImage.frame.size.height);
        [_rightButton addTarget:self action:@selector(rightTouch) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_rightButton];
    }
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return self;
}

- (void)updateCellStatus:(NSString *)leftName rightImage:(NSString *)rightName
{
    _leftImage.image = [UIImage imageNamed:leftName];
    _rightImage.image = [UIImage imageNamed:rightName];
}

- (void)leftTouch
{
}

- (void)rightTouch
{
}

@end
